package com.kuang.demo.service;


import com.kuang.demo.bean.acgBeanVo.*;
import com.kuang.demo.mapper.acg.StatGoodsDataMapper;
import com.kuang.demo.mapper.acg.StatOrderMapper;
import com.kuang.demo.mapper.acg.StatisticalReportMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ACG
 * @date 2020-11-03 17:35
 */
@Service
public class StatisticalReportServiceImpl implements StatisticalReportService {

    @Autowired
    StatisticalReportMapper statisticalReportMapper;
    @Override
    public StatUserData StatUserControl() {
        StatUserData statUserData = new StatUserData();
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("users");
        statUserData.setColumns(columns);
        List<StatUserDataRows>  rows = statisticalReportMapper.selectDayAndCountUser();
         statUserData.setRows(rows);
        return statUserData;
    }

    @Autowired
    StatOrderMapper statOrderMapper;
    @Override
    public StatOrderData StatOrderControl() {
        StatOrderData statOrderData = new StatOrderData();
        List<String> columns = new ArrayList<>();
        columns.add("day");  //日期
        columns.add("orders"); //订单量
        columns.add("customers");//下单用户
        columns.add("amount");//订单总额
        columns.add("pcr");//客单价
        statOrderData.setColumns(columns);
        List<StatOrderDataRows> rowsBeans = statOrderMapper.selectColumns();
        statOrderData.setRows(rowsBeans);
        statOrderData.setColumns(columns);
        return statOrderData;

    }

    @Autowired
    StatGoodsDataMapper statGoodsDataMapper;
    @Override
    public StatGoodsData StatGoodsControl() {
        StatGoodsData statGoodsData = new StatGoodsData();
        List<String> list = new ArrayList<>();
        list.add("day");
        list.add("orders");
        list.add("products");
        list.add("amount");
        statGoodsData.setColumns(list);

       List<StatGoodsDataRows> rows = statGoodsDataMapper.selectColumns();
       statGoodsData.setRows(rows);
        return statGoodsData;
    }
}
